import Vue from 'vue'

import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [





  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Perfect.team', icon: 'dashboard' }
    }]
  },
  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'CourseInformationManager',
    meta: { title: '课程信息管理', icon: 'example' },
    children: [
      {
        path: 'courseInformation',
        name: 'courseInformation',
        component: () => import('@/views/course/courseInformation/index'),
        meta: { title: '课程信息', icon: 'table' }
      },
      {
        path: 'courseCategory',
        name: 'courseCategory',
        component: () => import('@/views/course/courseCategory/index'),
        meta: { title: '课程类别', icon: 'tree' }
      }
    ]
  },

  {
    path: '/example2',
    component: Layout,
    redirect: '/example2/table',
    name: 'StudentManager',
    meta: { title: '学生管理', icon: 'example' },
    children: [
      {
        path: 'student',
        name: 'student',
        component: () => import('@/views/class/student/index'),
        meta: { title: '学生信息', icon: 'table' }
      },
      {
        path: 'classes',
        name: 'classes',
        component: () => import('@/views/class/classes/index'),
        meta: { title: '班级信息', icon: 'tree' }
      }
    ]
  },

  {
    path: '/example3',
    component: Layout,
    redirect: '/example3/table',
    name: 'TeacherManager',
    meta: { title: '教师管理', icon: 'example' },
    children: [
      {
        path: 'teacher',
        name: 'teacher',
        component: () => import('@/views/teachermanager/teacher/index'),
        meta: { title: '教师信息', icon: 'table' }
      },
      {
        path: 'department',
        name: 'department',
        component: () => import('@/views/teachermanager/department/index'),
        meta: { title: '院系信息', icon: 'nested' }
      }
    ]
  },

  {
    path: '/example4',
    component: Layout,
    redirect: '/example4/table',
    name: 'CourseAttenance',
    meta: { title: '考勤管理', icon: 'example' },
    children: [
      {
        path: 'courseAttenance',
        name: 'courseAttenance',
        component: () => import('@/views/attendance/courseAttenance/index'),
        meta: { title: '课程考勤', icon: 'table' }
      },
      {
        path: 'attendanceClerk',
        name: 'attendanceClerk',
        component: () => import('@/views/attendance/attendanceClerk/index'),
        meta: { title: '考勤记录员', icon: 'tree' }
      }
    ]
  },

  {
    path: '/process',
    component: Layout,
    redirect: '/example5/table',
    name: 'CourseProcessManager',
    meta: { title: '上课管理', icon: 'example' },
    children: [
      {
        path: 'courseProcess',
        name: 'courseProcess',
        component: () => import('@/views/process/courseProcess/index'),
        meta: { title: '课程记录', icon: 'table' }
      },
      {
        path: 'processRegistrar',
        name: 'processRegistrar',
        component: () => import('@/views/process/processRegistrar/index'),
        meta: { title: '课程记录员', icon: 'table' }
      }
    ]
  },

  {
    path: '/example6',
    component: Layout,
    redirect: '/example6/table',
    name: 'GradeManager',
    meta: { title: '成绩管理', icon: 'example' },
    children: [
      {
        path: 'courseGrade',
        name: 'courseGrade',
        component: () => import('@/views/grade/courseGrade/index'),
        meta: { title: '课程', icon: 'table' }
      },
      {
        path: 'studentGrade',
        name: 'studentGrade',
        component: () => import('@/views/grade/studentGrade/index'),
        meta: { title: '学生成绩', icon: 'tree' }
      }
    ]
  },

  {
    path: '/manager',
    component: Layout,
    redirect: '/manager/table',
    name: 'Manager',
    meta: { title: '平台管理', icon: 'example' },
    children: [
      {
        path: 'adminManager',
        name: 'adminManager',
        component: () => import('@/views/manager/adminManager/index'),
        meta: { title: '管理员信息', icon: 'table' }
      },
      {
        path: 'otherManager',
        name: 'otherManager',
        component: () => import('@/views/manager/otherManager/index'),
        meta: { title: '内部信息', icon: 'table' }
      },
      {
        path: 'userManager',
        name: 'userManager',
        component: () => import('@/views/manager/userManager/index'),
        meta: { title: '用户管理', icon: 'table' }
      }
    ]
  },

  {
    path: '/editCourseInformation',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editCourseInformation',
        component: () => import('@/views/course/editCourseInformation/index'),
        meta: { title: 'edit CourseInformation', icon: 'form' }
      }
    ]
  },

  {
    path: '/editCourseProcess',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editCourseProcess',
        component: () => import('@/views/process/editCourseProcess/index'),
        meta: { title: 'edit CourseProcess', icon: 'form' }
      }
    ]
  },

  {
    path: '/editProcessRegistrar',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editProcessRegistrar',
        component: () => import('@/views/process/editProcessRegistrar/index'),
        meta: { title: 'edit ProcessRegistrar', icon: 'form' }
      }
    ]
  },

  {
    path: '/editStudentGrade',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editStudentGrade',
        component: () => import('@/views/grade/editStudentGrade/index'),
        meta: { title: 'edit StudentGrade', icon: 'form' }
      }
    ]
  },
  {
    path: '/editCourseGrade',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index/:courseId',
        name: 'editCourseGrade',
        component: () => import('@/views/grade/editCourseGrade/index'),
        meta: { title: 'edit CourseGrade', icon: 'form' }
      }
    ]
  },
  {
    path: '/editCourseAttendance',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index/:courseId',
        name: 'editCourseAttendance',
        component: () => import('@/views/attendance/editCourseAttendance/index'),
        meta: { title: 'edit CourseAttendance', icon: 'form' }
      }
    ]
  },
  {
    path: '/editAttendanceClerk',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editAttendanceClerk',
        component: () => import('@/views/attendance/editAttendanceClerk/index'),
        meta: { title: 'edit AttendanceClerk', icon: 'form' }
      }
    ]
  },

  {
    path: '/editTeacher',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index/:workid',
        name: 'editTeacher',
        component: () => import('@/views/teachermanager/editTeacher/index'),
        meta: { title: 'edit Teacher', icon: 'form' }
      }
    ]
  },
  
  {
	    path: '/addTeacher',
	    hidden: true,
	    component: Layout,
	    children: [
	      {
	        path: 'index',
	        name: 'addTeacher',
	        component: () => import('@/views/teachermanager/addTeacher/index'),
	        meta: { title: 'add Teacher', icon: 'form' }
	      }
	    ]
	  },
  
  {
	    path: '/editDepartment',
	    hidden: true,
	    component: Layout,
	    children: [
	      {
	        path: 'index',
	        name: 'editDepartment',
	        component: () => import('@/views/teachermanager/editDepartment/index'),
	        meta: { title: 'edit Department', icon: 'form' }
	      }
	    ]
	  },

  {
    path: '/edit_manager',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index/:id',
        name: 'edit_manager',
        component: () => import('@/views/manager/edit/index'),
        meta: { title: '编辑管理员信息', icon: 'form' }
      }
    ]
  },

  {
    path: '/editClasses',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'editClasses',
        component: () => import('@/views/class/editClasses/index'),
        meta: { title: 'edit Classes', icon: 'form' }
      }
    ]
  },

  {
    path: '/editStudent',
    hidden: true,
    component: Layout,
    children: [
      {
        path: 'index/:courseId',
        name: 'editStudent',
        component: () => import('@/views/class/editStudent/index'),
        meta: { title: 'edit Student', icon: 'form' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
